﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Ruleweaver.Rules.CheckMethods;

namespace Ruleweaver.Annotation
{
	public sealed class CheckMatchesAttribute : CheckAttribute
	{
		public CheckMatchesAttribute(string pattern)
		{
			Contract.Requires(pattern != null);

			Pattern = pattern;
		}

		public string Pattern { get; private set; }

		public RegexOptions? Options { get; set; }

		protected override ICheckMethod GetCheckMethod()
		{
			return Options == null ? new MatchesMethod(Pattern) : new MatchesMethod(Pattern, Options.Value);
		}
	}
}